use std::error::Error;

pub type SeqResult<T> = Result<T,SeqError>;

#[derive(Debug)]
pub enum SeqError {
    Byte(crate::byte::ByteError),
    Fse(crate::fse::FseError),
    WorkSpace,
}

impl std::fmt::Display for SeqError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Byte(e) => write!(f,"[seq]{e}"),
            Self::Fse(e) => write!(f,"[seq]{e}"),
            Self::WorkSpace => write!(f,"[seq]workspace uninit"),
        }
    }
}

impl Error for SeqError { }

impl From<crate::byte::ByteError> for SeqError {
    fn from(value: crate::byte::ByteError) -> Self {
        Self::Byte(value)
    }
}

impl From<crate::fse::FseError> for SeqError {
    fn from(value: crate::fse::FseError) -> Self {
        Self::Fse(value)
    }
}